package com.module.businessLog;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import base.util.ConstantUnit;
import base.util.Page;
import base.util.StringUtil;

import com.module.businessLog.vo.LogCodeExplain;

public class BCodeExplainService {
	public BCodeExplainService(){}
	/**
	 * 分页查询编号说明信息
	 * @param log 编号说明对象
	 * @param start 开始分页行
	 * @param limit 每一页的最大行数
	 * @return 对象结果集
	 * @throws Exception
	 */
	 public Page toList(LogCodeExplain code,final Integer start,final Integer limit) throws Exception{
		    Page page = new Page();
            page.setStart(start);
            page.setLimit(limit);            
            Map<String,Object> map = new HashMap<String,Object>();
    	    map.put(ConstantUnit.O_PT, "toListbceBCodeExplain");
     	    map.put("page", page);
     	    map.put("explain", code);     	    
    	    return BusinessSocketClient.returnValue(map).getPage();
	}
	 
	 /**
	  * 新增编号说明
	  * @param code 编号说明对象
	  * @return 成功或者失败
	 * @throws Exception 
	  */
	 public  Map<String,Object> save(LogCodeExplain code,boolean isCheck) throws Exception{
		 Map<String,Object> resultMap = null;
		 boolean state = false;
		 if(isCheck){
			 resultMap = this.checkBCode(code);
			 state = (Boolean) resultMap.get("state");
		 }
		 if(state || !isCheck){
			 Map<String,Object> map = new HashMap<String,Object>();
			 map.put(ConstantUnit.O_PT, "savebceBCodeExplain");
			 map.put("explain", code); 
			 return BusinessSocketClient.returnValue(map).getResult();
		 }
		 return resultMap;
	 }
	 
	 /**
	  * 根据ID查询对象
	  * @param id 编号说明对象ID
	  * @return 编号说明对象
	  * @throws Exception
	  */
	 public LogCodeExplain findById(String id) throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		LogCodeExplain code = new LogCodeExplain();
		code.setId(id);
 	    map.put(ConstantUnit.O_PT, "findbceBCodeExplain");
  	    map.put("explain", code);  
  	    return BusinessSocketClient.returnValue(map).getExplain();
	 }
	 
	 /**
	  * 根据ID批量删除
	  * @param idArray ID数组 
	  * @return Map对象
	  * @throws Exception
	  */
	public Map<String,Object>  remove(List<String> idArray) throws Exception{
		String ids = StringUtil.getNewStrByList(idArray);
		LogCodeExplain obj = new LogCodeExplain();
		obj.setId(ids);	      
		Map<String,Object> map = new HashMap<String,Object>();
		map.put(ConstantUnit.O_PT,"delbceBCodeExplain");
		map.put("explain", obj);
		return BusinessSocketClient.returnValue(map).getResult();
	}
	
	/**
	 * 验证业务编号
	 * @param code 业务编号说明对象
	 * @return Map对象
	 * @throws Exception
	 */
	private  Map<String,Object> checkBCode(LogCodeExplain code) throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		map.put(ConstantUnit.O_PT, "checkBCodeBCodeExplain");
		map.put("explain", code); 
		return BusinessSocketClient.returnValue(map).getResult();
	}
	
	 /**
	  * 获取返回结果集
	  * @param map 
	  * @return
	  * @throws Exception
	  */
	
}
